// Copyright (C) 2019-2021
// 511972386@qq.com

#ifndef SOMEIP_APP_SERVICE_HPP_
#define SOMEIP_APP_SERVICE_HPP_

#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
#include <csignal>
#endif

#include <vsomeip/vsomeip.hpp>
#include <chrono>
#include <thread>
#include <condition_variable>
#include <mutex>
#include <iostream>


namespace someip_app {

class someip_service {

public:
    someip_service();
    virtual ~someip_service();

    bool init();
    void start();
    void stop();
    void terminate();
    void on_state_cbk(vsomeip::state_type_e _state);
    void on_message_cbk(const std::shared_ptr<vsomeip::message> &_request);

private:
    std::shared_ptr<vsomeip::runtime> rtm_;
    std::shared_ptr<vsomeip::application> app_;
    bool stop_;
    std::mutex mutex_;
    std::condition_variable condition_;
    std::thread stop_thread_;
};

} // namespace someip_app

#endif // SOMEIP_APP_SERVICE_HPP_
